package com.dd.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.dd.mapper.FolderMapper;
import com.dd.mapper.UserFoldFileMapper;
import com.dd.pojo.entry.Folder;
import com.dd.pojo.entry.UserFoldFile;
import com.dd.service.SearchService;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
@RequiredArgsConstructor
@Slf4j
public class SearchImpl implements SearchService {

    private final UserFoldFileMapper userFoldFileMapper;
    private final FolderMapper folderMapper;
    @Override
    public List<UserFoldFile> SearchFiles(String userId, String fileName) {
        LambdaQueryWrapper<UserFoldFile> wrapper = new LambdaQueryWrapper<UserFoldFile>();
        wrapper.like(UserFoldFile::getFileName,fileName).eq(UserFoldFile::getUserId,userId);
        List<UserFoldFile> userFoldFiles = userFoldFileMapper.selectList(wrapper);
        return userFoldFiles;
    }

    @Override
    public List<Folder> SearchFolder(String id, String filename) {
        List<Folder> folders = userFoldFileMapper.searchFolder(id,filename);
        return folders;
    }

}

